package sendorder;

import java.util.ArrayList;
import java.util.List;

import dao.DataLoader;
import datacontainers.Order;
import datacontainers.OrderItem;

public class OrderCollector {

    private Order fullOrder = new Order();
    private List<Order> orders = new ArrayList<Order>();
    private List<String> users = new ArrayList<String>();
    private Double fullCost = 0.0;
    private Double meanCost = 0.0;

    public OrderCollector(DataLoader dao) {
	orders = dao.getTomorrowOrders();

	for (Order t : orders) {
	    users.add(t.getUser().getName());
	    for (OrderItem d : t.getItems()) {
		fullOrder.setDishCount(d.getDish(),
			fullOrder.getDishCount(d.getDish()) + d.getCount());
		fullCost += d.getCount() * d.getDish().getCost();
	    }
	}
	meanCost = fullCost / orders.size();

    }

    public List<String> getUsers() {
	return users;
    }

    public Order getFullOrder() {
	return fullOrder;
    }

    public double getFullCost() {
	return fullCost;
    }

    public double getMeanCost() {
	return meanCost;
    }

}
